package org.dromara.community.controller;

import io.swagger.v3.oas.annotations.Operation;
import org.dromara.community.entity.AsSpaceReservation;
import org.dromara.community.entity.dto.AsLeaveIdleDTO;
import org.dromara.community.entity.dto.AsSpaceReservationDTO;
import org.dromara.community.mapper.AsSpaceReservationMapper;
import org.dromara.community.service.AsSpaceReservationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 邻里生活(空间预约)
 *
 * @description :
 * @create :2023/4/24 11:04
 **/
@RestController
@RequestMapping("/spaceReservation")
public class AsSpaceReservationController {


    @Autowired
    private AsSpaceReservationService asSpaceReservationService;


    // 使用@GetMapping注释指定处理HTTP GET请求，路径为"/selectAll"
// 操作注释@Operation用于API文档生成工具，如Swagger，提供接口的简要说明
    @GetMapping("/selectAll")
    @Operation(summary = "查询邻里生活(空间预约)")
    public ResponseEntity<List<AsSpaceReservationDTO>> selectAll() {
        // 调用服务方法获取所有空间预约信息
        List<AsSpaceReservationDTO> reservations = asSpaceReservationService.getAllReservations();
        // 返回HTTP响应，状态码为200(OK)，并携带预约信息作为响应体
        return ResponseEntity.ok(reservations);
    }


    // 通过GET请求访问/selectAlls路径，用于查询邻里生活（社区闲置）信息
    @GetMapping("/selectAlls")
// 操作级别的注解，用于OpenAPI文档，描述此请求的作用
    @Operation(summary = "查询邻里生活(社区闲置)")
    public ResponseEntity<List<AsLeaveIdleDTO>> selectAllIds() {
        // 调用asSpaceReservationService的getAll方法，获取所有邻里生活信息
        List<AsLeaveIdleDTO> reservations = asSpaceReservationService.getAll();
        // 返回一个HTTP响应，携带状态码200和查询到的邻里生活信息列表
        return ResponseEntity.ok(reservations);
    }


}
